<?php

namespace plugin\admin\app\model;

use plugin\admin\app\model\Base;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * @property integer $id (主键)
 * @property string $name 分类名称
 * @property string $created_at 创建时间
 * @property string $updated_at 更新时间
 * @property string $deleted_at 软删除
 */
class BlogCategory extends Base
{
    use SoftDeletes;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'blog_category';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * 指示模型主键是否递增
     *
     * @var bool
     */
    public $incrementing = true;

    /**
     * 指示是否自动维护时间戳
     *
     * @var bool
     */
    public $timestamps = true;

    /**
     * 获取分类下的文章
     */
    public function articles()
    {
        return $this->hasMany('plugin\admin\app\model\BlogArticle', 'cate_id', 'id');
    }
}